//
//  括号匹配.cpp
//  408数据结构
//
//  Created by Cai Yuanhao on 2022/3/26.
//

#include "SqStack.hpp"
#include <stdio.h>
#include <string.h>
bool bracketCheck(char str[], int length)
{
    SqStack S;
    initStack(S);
    for (int i = 0; i < length; i++)
    {
        if (str[i] == '(' || str[i] == '[' || str[i] == '{')
        {
            Push(S, str[i]);
        }
        else
        {
            if (isEmpty(S))
                return false;
            char topElem;
            Pop(S, topElem);
            if (str[i] == ')' && topElem != '(')
                return false;
            if (str[i] == ']' && topElem != '[')
                return false;
            if (str[i] == '{' && topElem != '}')
                return false;
        }
    }
    return isEmpty(S);
}

int main()
{
    char a[20];
    while (1) {
        
        printf("input:");
        scanf("%s",a);
//        printf("%d\n",bracketCheck(a, strlen(a)));
    }
    return 0;
}
